# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
===========================
@Time : 2022/10/10 0010 23:48
@Author : 测试开发工程师
@File : login_page.py
@Software: PyCharm
============================
"""

from last_testweb.Litemall_Project.page_objects.base_page import BasePage
from selenium.webdriver.common.by import By


class LoginPage(BasePage):
    _INPUT_USERNAME = (By.XPATH, "//*[@name='username']")
    _INPUT_PASSWORD = (By.XPATH, "//*[@name='password']")
    _BNT_LOGIN = (By.CSS_SELECTOR, "button.el-button")

    def login(self):
        from last_testweb.Litemall_Project.page_objects.index_page import IndexPage
        # 输入用户名
        self.do_send_keys(*self._INPUT_USERNAME, "admin123")
        # 输入密码
        self.do_send_keys(*self._INPUT_PASSWORD, "admin123")
        # 点击登录
        self.do_click(*self._BNT_LOGIN)

        return IndexPage(self.driver)
